<?php

/**
 * PageController.php
 *
 * Holds abstract class PageController
 *
 * @package Application
 * @subpackage Controllers
 */

/**
 * PageController
 *
 * Public page base controller
 *
 * @package Application
 * @subpackage Controllers
 */
abstract class PageController extends Controller {

	/**
	 * Initializes page
	 *
	 * @return Controller (fluent interface)
	 */
	public function init() {
		parent::init();
		
		$this->set('language', $this->getConfig()->get('language'));
		$this->getLanguage()->import('common.php')->import('error.php');
		$this->set($this->getLanguage()->get('menu')->export());
		
		$this->local = $this->getLanguage();

		
		$session = Session::instance();

		if(isset($session->user_id)){
			$mUser = new Mapper_User($this->getDb());
			$this->user = $mUser->{$session->user_id};
		}
		
		$mNews = new Mapper_News($this->getDb());
		$this->news = $mNews->getAll();
		
		$this->module = strtolower($this->_module);
		$this->controller = strtolower(substr($this->_controller,0,strlen($this->_controller) - strlen("Controller")));
		$this->action = strtolower(substr($this->_action,6));
			
		$this->title = "Zumba Workouts Amsterdam - Ditch the Routine, Join the party!";
		$this->subtitle = "";
		
		return $this;
	}
}
